package com.example.fitnessservice.module.utils;

import java.util.Calendar;
import java.util.Date;

/**
 * @author feng
 * @version 1.0
 * @&#064;description: TODO
 * @&#064;date 2022/11/24 18:51
 */
public class GenerateOrderNo {
    public static String generateOrderNo(Integer userId, Integer courseId){
        Calendar calendar=Calendar.getInstance();
        String yearStr=String.valueOf(calendar.get(Calendar.YEAR));
        String monthStr=String.valueOf(calendar.get(Calendar.MONTH));
        String dayStr = String.valueOf(calendar.get(Calendar.DAY_OF_MONTH));
        if (calendar.get(Calendar.MONTH)<10) {
        monthStr="0"+monthStr;
        }if (calendar.get(Calendar.DAY_OF_MONTH) <10) {
            dayStr="0"+dayStr;
        }

        String userStr= String.valueOf(Math.abs(9999-userId)%10000);
        String couseStr= String.valueOf(Math.abs(999-courseId)%1000);
        return yearStr+monthStr+dayStr+couseStr+userStr;
    }
}
